/////////////////多态   也就是鸭子类型   他们具有相同的特征，但是调用方法都是一样的
class AbstractActor {
  constructor() {
    this.name = ""
  }
  clone() {
    return Object.create(this)
  }
  run() {
    throw new Exception("抽象方法不能直接调用")
  }
}

class NormalActor extends AbstractActor {
  run() {
    console.log(this.name + '跑')
  }
}

class FlyActor extends AbstractActor {
  run() {
    console.log(this.name + '飞')
  }
}

class GameManager {
  run(actor) {
    const actor1 = actor.clone();
    actor1.name = "角色1"
    const actor2 = actor.clone();
    actor2.name = "角色2"
    const actor3 = actor.clone();
    actor3.name = "角色3"
    actor1.run()
    actor2.run()
    actor3.run()
  }
}
// new GameManager().run(new NormalActor())


const normalActor = {
  name: '无名角色',
  run: function() {
    console.log(this.name + '跑')
  }
}
const flyActor = {
  name: '无名角色',
  run: function() {
    console.log(this.name + '飞')
  }
}
const run = (actor) => {
    const actor1 = Object.create(actor);
    actor1.name = "角色1"
    actor1.run()
    const actor2 = Object.create(actor);
    actor2.name = "角色2"
    actor2.run()
    const actor3 = Object.create(actor);
    actor3.name = "角色3"
    actor3.run()
}
run(normalActor)